package zx.x.modules.app.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import zx.x.modules.app.entity.ActivityRoomPriceEntity;
import zx.x.modules.app.entity.YwglEntity;
import zx.x.modules.app.vo.MerchantVo;
import zx.x.modules.common.entity.CreativeGoodsEntity;
import zx.x.modules.common.service.CreativeGoodsService;
import zx.x.common.utils.PageUtils;
import zx.x.common.utils.R;



/**
 * 文创商品表
 *
 * @author x
 * @email x
 * @date 2023-01-05 16:44:49
 */
@RestController
@RequestMapping("/app/creativegoods")
public class CreativeGoodsController {
    @Autowired
    private CreativeGoodsService creativeGoodsService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(CreativeGoodsEntity c){
        QueryWrapper<CreativeGoodsEntity> queryWrapper = new QueryWrapper<CreativeGoodsEntity>();
        queryWrapper.gt("sl",0).eq("delete_flag","0").eq("status","0");
        Page page = PageHelper.startPage(c.getPage(),c.getLimit());
        List<CreativeGoodsEntity> list = creativeGoodsService.list(queryWrapper);
        return R.ok().put("page", list).put("pages",page.getPages()).put("total",page.getTotal());
    }

    /**
     * 首页下边那个列表
     */
    @RequestMapping("/syList")
    public R syList(CreativeGoodsEntity c){
        QueryWrapper<CreativeGoodsEntity> queryWrapper = new QueryWrapper<CreativeGoodsEntity>();
        queryWrapper.eq("delete_flag","0").eq("status","0").eq("sfzssy","1").orderBy(true,false,"px");
        Page page = PageHelper.startPage(c.getPage(),c.getLimit());
        List<CreativeGoodsEntity> list = creativeGoodsService.list(queryWrapper);
        return R.ok().put("page", list).put("pages",page.getPages()).put("total",page.getTotal());
    }


    /**
     * 信息
     */
    @RequestMapping("/queryByid")
    public R queryByid(Integer id){
		CreativeGoodsEntity creativeGoods = creativeGoodsService.getById(id);
        return R.ok().put("creativeGoods", creativeGoods);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(CreativeGoodsEntity creativeGoods){
		creativeGoodsService.save(creativeGoods);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(CreativeGoodsEntity creativeGoods){
		creativeGoodsService.updateById(creativeGoods);
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(Integer[] ids){
		creativeGoodsService.removeByIds(Arrays.asList(ids));
        return R.ok();
    }

}
